package net.atlasdream.mybatis.demo;

import com.alibaba.druid.pool.DruidDataSource;
import org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory;

/**
 * druid data source factory.
 */
public class DruidDataSourceFactory extends UnpooledDataSourceFactory {

//    private final DataSource dataSource;
//    private Properties props;

    public DruidDataSourceFactory() {
        this.dataSource = new DruidDataSource();
    }

//    @Override
//    public void setProperties(Properties props) {
//        super.setProperties(props);
//    }

//    @Override
//    public DataSource getDataSource() {
//        DruidDataSource dds = (DruidDataSource) dataSource;
//        dds.setDriverClassName(this.props.getProperty("driver"));
//        dds.setUrl(this.props.getProperty("url"));
//        dds.setUsername(this.props.getProperty("username"));
//        dds.setPassword(this.props.getProperty("password"));
//        // 其他配置可以根据MyBatis主配置文件进行配置
//        try {
//            dds.init();
//        } catch (SQLException e) {
//            e.printStackTrace();
//        }
//        return dds;
//    }
}
